<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
var s = "abcdefgh";
//获取子字符串
// 3种
// s.substring  参数不能是负数. 如果是负就当做0来处理
var s1 = s.substring(0, 3);
console.log(s1);
// s.substr(startIndex, len)
var s2 = s.substr(6, 3)
console.log(s2);
// s.slice()
console.log(s.slice(-4, -1));
</script>
</body>
</html>